<?php

/**
 * \class user_details_handler
 * \brief This class handles current user details.
 * \author  Salman Noor
 */
class user_details_handler {

    /**
     * \brief Data member to handle business user object.
     */
    private $bussinessUserDBObject;
    /**
     * \brief Data member storing the current user name of the business user.
     */
    private $currentUserName;
    /**
     * \brief private data member to access functionality defined in class html_elements_builder
     */
    private $html_buillder;

    /**
     * \brief Constructor to initialise private data variables of the
     * user_details_handler class.
     */
    public function __construct($userName) {
        $this->currentUserName = $userName;
        $this->bussinessUserDBObject = new database_tables_handler();
        $this->html_buillder = new html_elements_builder();
    }

    /**
     * \brief This function builds the html content of the business details handler.
     * \return This function returns the html content of the business details
     *  handler.
     */
    private function buildUserDetailsHandler() {
        $userDetails = $this->bussinessUserDBObject->getBusinessUserDetails($this->currentUserName);
        $userDetailsList = "<ol id='selectable'>";
        $userDetailsList .= "<li class='ui-widget-content'><b>User's First Name: </b><span id='fnameListContainer'> $userDetails[buser_fname] </span></li>";
        $userDetailsList .= "<li class='ui-widget-content'><b>User's Surname Name: </b><span id='lnameListContainer'> $userDetails[buser_lname] </span></li>";
        $userDetailsList .= "<li class='ui-widget-content'><b>User's Email Address: </b><span id='uemailListContainer'> $userDetails[buser_email]</span> </li>";
        $userDetailsList .= "<li class='ui-widget-content'><b>User's User Name: </b><span id='unameListContainer'> $userDetails[buser_username]</span> </li>";
        $userDetailsList .="</ol>";
        $userDetailsList .= $this->html_buillder->buildButton("updateUserDetails", "Update User Details", "updateUser");
        $userDetailsList .= $this->html_buillder->buildHiddenInput("userFirstName", $userDetails['buser_fname']);
        $userDetailsList .= $this->html_buillder->buildHiddenInput("userLastName", $userDetails['buser_lname']);
        $userDetailsList .= $this->html_buillder->buildHiddenInput("userEmail", $userDetails['buser_email']);
        $userDetailsList .= $this->html_buillder->buildHiddenInput("userUserName", $userDetails['buser_username']);
        $userDetailsList .= $this->html_buillder->buildHiddenInput("userPassword", $userDetails['buser_pword']);

        return $userDetailsList;
    }

    /**
     * \brief This function builds the html content of the business details handler.
     * \return This function returns the html content of the business details
     *  handler for displaying.
     */
    public function showBUserDetails() {
        return $this->buildUserDetailsHandler();
    }

}
?>
